package com.petplanet.common.ui.widgets

import androidx.compose.foundation.background
import androidx.compose.foundation.gestures.Orientation
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp

@Composable
fun AppHeaderBar(
    heightDp: Dp = 48.dp,
    backgroundColor: Color = MaterialTheme.colorScheme.background,
    leftContent: @Composable () -> Unit,
    centerContent: @Composable () -> Unit,
    rightContent: @Composable () -> Unit,
    leftWeight: Float = 1f,
    centerWeight: Float = 1f,
    rightWeight: Float = 1f,
    dividerVisible: Boolean = false
) {
    Row(
        modifier = Modifier
            .background(backgroundColor)
            .height(heightDp)
            .padding(horizontal = 16.dp, vertical = 8.dp)
            .fillMaxWidth(),
        horizontalArrangement = Arrangement.SpaceBetween,
        verticalAlignment = Alignment.CenterVertically
    ) {
        Row(
            modifier = Modifier.weight(leftWeight),
            horizontalArrangement = Arrangement.Start
        ) {
            leftContent()
        }

        Row(
            modifier = Modifier.weight(centerWeight),
            horizontalArrangement = Arrangement.Center
        ) {
            centerContent()
        }

        Row(
            modifier = Modifier.weight(rightWeight),
            horizontalArrangement = Arrangement.End
        ) {
            rightContent()
        }
    }

    if (dividerVisible) {
        CustomDivider(orientation = Orientation.Horizontal, color = MaterialTheme.colorScheme.outline)
    }
}